
const { Service } = require('egg');
class ExcelService extends Service { 
    async saveTable(multipleRowsData,table) { 
      const transaction = await this.app.mysql.beginTransaction();  
      try {
         for (const row of multipleRowsData) {
           await transaction.insert(table, row);  
         } 
         await transaction.commit(); // 提交事务
         this.ctx.body = 'Multiple rows inserted successfully';
       } catch (err) {
         await transaction.rollback(); // 回滚事务
         this.ctx.body = 'Error occurred, transaction rolled back';
       }
    }
}


module.exports = ExcelService;